// 点击事件部分代码
$("#tixBuy").click( async e => {
    if(!JUST.Bridges.Metamask || !JUST.Bridges.Metamask.signedIn)
        return alertify.alert(\"You are not signed into metamask.\")
        let correctNetwork  = await JUST.checkNetwork()
        if(!correctNetwork)
            return
        alertify.alert(\"You are not in the correct network. Please navigate to <a style='color: #1e10f8;text-decoration: underline;' href='https://testnet.teamjust.io'>the testnet portal</a> and follow the instructions.\")
        let count = String($("#tixToBuy").val())
                    .replace("keys", "")
                    .replace("key", "")
                    .replace("Keys", "")
                    .replace("Key", "")
        if(!Number.isInteger(parseInt(count)))
            return
        var masternode = window.localStorage.getItem("masternode") ? window.localStorage.getItem("masternode") : "0x0"
        count = BN((parseInt(count)) * 1e18)
        try {
            priceQuotation = await JUST.Bridges.Browser.contracts.Fomo3D.read('iWantXKeys', count)
            $('#loading').modal({backdrop: 'static', keyboard: false})
            let team = $("input[name='teamselect']:checked").val()
            if(!team) team = 0
            let receipt = await JUST.Bridges.Metamask.contracts.Fomo3D.purchaseKeys(BN(priceQuotation).plus(100).toString(), team)
            alertify.log(`Your ticket purchasing request has been submitted to the blockchain!`)
            jQuery('#loading').modal('hide')
            console.log(receipt)
        } catch (e) {
            alertify.log(`Buy order has been cancelled.`)
            jQuery('#loading').modal('hide')
        }
    })
    // 倒计时部分代码
    // if(Math.floor( JUST.date().getTime() / 1000) > (parseInt(JUST.Cache.currentRound[3]) - 90) && $this.gracePeriod) {$this.gracePeriod = false// pepefunction pepe(){$(".animation").animate({bottom: "-30px"}, "slow");    $(".animation").animate({left: "100%"}, "slow", function () {      $(this).removeAttr('style');      });}pepe()// clear timer from stackclearInterval(window.globalTimerObject)$this.refresher()}if(!expired){if($this.gracePeriod){let actualTime = parseDifference(new Date(parseInt(JUST.Cache.currentRound[3]) - 90), JUST.date())jQuery(".headtimer").text(`${(actualTime.hours == "00" ? "" : actualTime.hours + ":") }${actualTime.minutes}:${actualTime.seconds}`)} else {jQuery(".headtimer").text(`${(data.hours == "00" ? "" : data.hours + ":") }${data.minutes}:${data.seconds}`)}jQuery(".boxtimer").text(`${(data.hours == "00" ? "" : data.hours + ":") }${data.minutes}:${data.seconds}`)var timeTotal = parseInt(parseInt(JUST.Cache.currentRound[4]) - parseInt(JUST.Cache.currentRound[4])) + 3600var timeRemaining = parseInt(JUST.Cache.currentRound[3]) - now var timePercentage = 100 - timeRemaining / (timeTotal / 100)//console.log(timeTotal, timeRemaining, Math.floor(timePercentage))jQuery(".progress-bar.boxglow").css('width', `${Math.floor(timePercentage)}%`)} else {jQuery("#quotes").removeClass("active")
    jQuery(".headtimer")
        .text(`${(actualTime.hours == "00" ? "" : actualTime.hours + ":") }${actualTime.minutes}:${actualTime.seconds}`)}
    else {
        jQuery(".headtimer").text(`${(data.hours == "00" ? "" : data.hours + ":") }${data.minutes}:${data.seconds}`)}
        jQuery(".boxtimer").text(`${(data.hours == "00" ? "" : data.hours + ":") }${data.minutes}:${data.seconds}`)
        var timeTotal = parseInt(parseInt(JUST.Cache.currentRound[4]) - parseInt(JUST.Cache.currentRound[4])) + 3600
        var timeRemaining = parseInt(JUST.Cache.currentRound[3]) - now
        var timePercentage = 100 - timeRemaining / (timeTotal / 100)



        setTimeout(function() {
            $('.tutorialArrow').fadeOut('fast');}, 20000);
            // <-- time in milliseconds</script><!-- fomo--><!-- NOTE: Displays the current pot size in ETH as well as time left in current round -->
            <div class="blurryboy" if={!$this.gracePeriod}></div>
            <div class="blurryboydark" if={$this.gracePeriod}></div>
            <div class="jumbotron rounded-0 text-center text-light teaser-cover" if={!$this.roundHasPassed}>
            <!--<div class="grid-container" if={!$this.gracePeriod}><div id="hdgraphics" class="grid-top"></div></div> -->
            <div class="container"><h4 class="display-4 scammed" style="font-style: italic;" if={!$this.playerIsLeader && JUST.Cache.currentRound[8] && JUST.Cache.currentRound[8] !=  "0x0000000000000000000000000000000000000000000000000000000000000000"}>{JUST.Bridges.Browser.web3.utils.toAscii(JUST.Cache.currentRound[8])} is</h4><h4 class="display-4 scammed" style="font-style: italic;" if={!$this.playerIsLeader && JUST.Cache.currentRound[8] && JUST.Cache.currentRound[8] ==  "0x0000000000000000000000000000000000000000000000000000000000000000"}>someone else is</h4><h1 class="display-1 scammed" if={!$this.playerIsLeader && !$this.gracePeriod}>EXIT SCAMMING</h1><h1 class="display-1 scammed" if={$this.playerIsLeader && !$this.gracePeriod}>YOU ARE EXIT SCAMMING</h1><h1 class="display-1 scammed" if={!$this.playerIsLeader && $this.gracePeriod}>ICO FUNDING</h1><h1 class="display-1 scammed" if={$this.playerIsLeader &&